home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_09_04
/
9n04090a
< prev
next >
Wrap
Text File
|
1991-02-04
|
942b
|
31 lines
int DirSort(const void *pItem1, const void *pItem2)
{
CHAR ach1[MAXPATH], ach2[MAXPATH];
register CHAR *psz;
/*
* Copy the path names to buffers
*/
strcpy(ach1,((DIR_INFO *)pItem1)->achPathName);
strcpy(ach2,((DIR_INFO *)pItem2)->achPathName);
/*
* Convert all backslashes (\) to hex 01s. Since the
* backslash falls in the middle of the valid ASCII
* codes for directory names, it could (and I have
* seen it) cause the strcmp() to wrongly compare two
* directories when they are different levels.
*/
for (psz = ach1; *psz; psz++)
if (*pse == '\\')
*psz = 0x01;
for (psz = ach2; *psz; psz++)
if (*psz == '\\')
*psz = 0x01;
return(strcmp(ach1,ach2));
}